﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace UFSSWebApp
{
    public partial class message : System.Web.UI.Page
    {
        UFSSservicereference.UserCreds uc = new UFSSservicereference.UserCreds();
        UFSSservicereference.UFSSserviceSoapClient ussc = new UFSSservicereference.UFSSserviceSoapClient();

        protected void Page_Load(object sender, EventArgs e)
        {
            uc = (UFSSservicereference.UserCreds)Session["usercreds"];
            txtReciever.Text = Session["reciever"].ToString();
            try
            {
                txtSubject.Text = "Re: " + Session["reply"].ToString();
                txtSubject.ReadOnly = true;
                txtSubject.Enabled = false;
            }
            catch
            {
            }
        }

        protected void btnSend_Click(object sender, EventArgs e)
        {
            try
            {
                if(txtSubject.Text.Equals(null))
                    ussc.sendMessage(uc, txtReciever.Text, txtMessage.Text, "No Subject");
                else
                    ussc.sendMessage(uc, txtReciever.Text, txtMessage.Text, txtSubject.Text);

                Session.Remove("reciever");
                Response.Redirect("~/home.aspx");
            }
            catch
            {
                lblError.Text = "Error sending message.";
            }
        }
    }
}